
module singleOut4(
  input [3:0] in,
  output reg [3:0] out,
  input [3:0] def,
  output reg [1:0] addr);
always @(*) begin
  casez (in)
    4'b???1:begin out <= 4'b0001;addr <= 2'h0; end
    4'b??10:begin out <= 4'b0010;addr <= 2'h1; end
    4'b?100:begin out <= 4'b0100;addr <= 2'h2; end
    4'b1000:begin out <= 4'b1000;addr <= 2'h3; end
    default:begin out <=     def;addr <= 2'h0; end
  endcase
end
endmodule


module singleOut2(
  input [1:0] in,
  output reg [1:0] out,
  input [1:0] def,
  output reg addr);
always @(*) begin
  casez (in)
    2'b?1  :begin out <= 2'b01;addr <= 1'h0; end
    2'b10  :begin out <= 2'b10;addr <= 1'h1; end
    default:begin out <=   def;addr <= 1'h0; end
  endcase
end
endmodule


module singleOut32(
  input [31:0] in,
  output reg [4:0] out);
always @(*) begin
  casez (in)
    32'b???????????????????????????????1:begin out <= 5'h00; end
    32'b??????????????????????????????10:begin out <= 5'h01; end
    32'b?????????????????????????????100:begin out <= 5'h02; end
    32'b????????????????????????????1000:begin out <= 5'h03; end
    32'b???????????????????????????10000:begin out <= 5'h04; end
    32'b??????????????????????????100000:begin out <= 5'h05; end
    32'b?????????????????????????1000000:begin out <= 5'h06; end
    32'b????????????????????????10000000:begin out <= 5'h07; end
    32'b???????????????????????100000000:begin out <= 5'h08; end
    32'b??????????????????????1000000000:begin out <= 5'h09; end
    32'b?????????????????????10000000000:begin out <= 5'h0A; end
    32'b????????????????????100000000000:begin out <= 5'h0B; end
    32'b???????????????????1000000000000:begin out <= 5'h0C; end
    32'b??????????????????10000000000000:begin out <= 5'h0D; end
    32'b?????????????????100000000000000:begin out <= 5'h0E; end
    32'b????????????????1000000000000000:begin out <= 5'h0F; end
    32'b???????????????10000000000000000:begin out <= 5'h10; end
    32'b??????????????100000000000000000:begin out <= 5'h11; end
    32'b?????????????1000000000000000000:begin out <= 5'h12; end
    32'b????????????10000000000000000000:begin out <= 5'h13; end
    32'b???????????100000000000000000000:begin out <= 5'h14; end
    32'b??????????1000000000000000000000:begin out <= 5'h15; end
    32'b?????????10000000000000000000000:begin out <= 5'h16; end
    32'b????????100000000000000000000000:begin out <= 5'h17; end
    32'b???????1000000000000000000000000:begin out <= 5'h18; end
    32'b??????10000000000000000000000000:begin out <= 5'h19; end
    32'b?????100000000000000000000000000:begin out <= 5'h1A; end
    32'b????1000000000000000000000000000:begin out <= 5'h1B; end
    32'b???10000000000000000000000000000:begin out <= 5'h1C; end
    32'b??100000000000000000000000000000:begin out <= 5'h1D; end
    32'b?1000000000000000000000000000000:begin out <= 5'h1E; end
    32'b10000000000000000000000000000000:begin out <= 5'h1F; end
    default                             :begin out <= 5'h00; end
  endcase
end
endmodule
